Skip to main content

Mini Apps

Write small useful apps using WL, JS, whatever with GUI and isolated resources

WLJS Notebook can be used as a runtime for mini apps. It is 1 window app, which uses the full capabilities of a normal notebook (similar to Wolfram CDF or LabView programs) and runs in the isolated generated context.

We have a dedicated section on our website - Mini Apps, > where we showcase some of the mini apps we’ve developed.

note

Widgets are shipped as a single executable file with .wlw extension. By changing this extension to .wln you can restore the source notebook.

How write a mini app using notebook

In general you can thing about a mini app if it was an output of a single cell projected to a window. The following rules are applied in addition

  • The default context ($Context) of all symbols is randomly generated and will be unique for each running instance of your widget
  • All initialization cells will be executed automatically on the startup of the widget
  • The output of the last input cell will be the window of your widget
  • An app will use the first available computation Kernel in your system

Apart from that the program for the widget is just a plain WLJS notebook. You can leave there cells for testing, debugging with no impact.

  • export it using Share menu

tip

Use WLX cell as the output

info

See more tutorials on making mini apps in Advanced section - Advanced/Mini Apps

Example 1

Let's write the simples possible interactive widget

note

There is no need in evaluation of any of those cells for widget to work later

Initialization cell
equation[x_,n_] := Sum[(Sin[2\[Pi](2j - 1) x])/(2j - 1), {j, 1, n}]
Last input cell
ManipulatePlot[equation[x,n]//Re, {x, -1,1}, {n, 1,10,1}]

Then you can simple press Share and locate mini app or WLJS Widget

As the result you will get .wlw file. Open it anytime on any machine with WLJS Notebook installed

Example 2

Last input cell
Module[{
text = "Hello World"
},
Column[{
EventHandler[InputText[text], (text = #)&],
Graphics[Table[{
RandomColor[],
Rotate[
Text[text // Offload, RandomReal[{-1,1}, 2]],
RandomReal[{0, 3.14}]
]
}, {40}]]
}]
]

Tips

tip

Utilize WLX cells for the best customization of the GUI

tip

Track opened windows using CurrentWindow inside event generating functions (buttons or other UI elements used on the window) and free the resources once it has been closed. See also how it is done in Multi-window app

Examples

See Mini apps section in the top navigation menu